package com.gitee.feizns.quickstart.mybatis.flex.jpa;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.gitee.feizns.quickstart.ddl.annotation.Comment;
import com.mybatisflex.annotation.KeyType;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
 * 自增主键实体
 * @author feizns
 * @since 2022/10/8
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@MappedSuperclass
@JsonPropertyOrder(AutoIdPojo.keyColumnName)
public abstract class AutoIdPojo<T extends AutoIdPojo<T>> extends Pojo<T> {

    /**
     * （主键）编号
     */
    @Id
    @Comment("自增主键编号")
    @com.mybatisflex.annotation.Id(keyType = KeyType.Auto)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = keyColumnName, nullable = false, columnDefinition = "BIGINT UNSIGNED")
    protected Long id;

}
